//
//  main.m
//  03_NSStringHomework
//
//  Created by 徐昊 on 16/7/6.
//  Copyright © 2016年 徐昊. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "Book.h"
#import "BookManager.h"
int main(int argc, const char * argv[]) {

//    1.截取字符串 "20|https://www.baidu.com" 中 "|" 前面和后⾯的字符串, 并输出
//    2.向可变数组里存储 int、float、double、BOOL类型等数据(不能使用字面量)
//    3.实现图书管理系统(BookManager类)：
//    (1).使用数组管理所有书籍(Book类)。
//    (2).BookManager类属性数组可以添加、删除。
//    (3).可以从数组根据书名查找书籍，并修改书籍的价格。
//    (4).展示所有书籍清单（书名）
    
    // 1.
    NSString *urlString = @"20|http://www.baidu.com";
    NSArray *urlArray = [urlString componentsSeparatedByString:@"|"];
    NSLog(@"%@", urlArray);
    
    // 2.
    BOOL hasBack = 1;
    int a = 2;
    float b = 3.3;
    double c = 4.2;
    NSNumber *num1 = [NSNumber numberWithBool:hasBack];
    NSNumber *num2 = [NSNumber numberWithInt:a];
    NSNumber *num3 = [NSNumber numberWithFloat:b];
    NSNumber *num4 = [NSNumber numberWithDouble:c];
    NSMutableArray *mArr = [NSMutableArray arrayWithObjects:num1, num2, num3, num4, nil];
    NSLog(@"%@", mArr);
    
    // 3.
    Book *book1 = [Book bookWithPrice:@"25" name:@"格林童话"];
    Book *book2 = [Book bookWithPrice:@"34" name:@"伊索寓言"];
    Book *book3 = [Book bookWithPrice:@"10" name:@"十万个为什么"];
    Book *book4 = [Book bookWithPrice:@"15" name:@"老司机"];
    
    BookManager *library = [[BookManager alloc] init];
    library.mArrOfBook = [NSMutableArray arrayWithObjects:book1, book2, book3, book4, nil];
    [library addBookName:@"十万个为什么" price:@"55"];
    [library addBookName:@"啪啪啪" price:@"34"];
    [library searchBook:@"啪啪啪"];
    [library correctBook:@"啪啪啪" price:@"56"];
    [library allBooksInformation];
    [library deleteBookName:@"啪啪啪"];
    [library allBooksInformation];
    
    return 0;
}
